import { request } from "../utils";
import type { Commodity } from "./shops";
const URL = 'takeAway_order'

export type addOrderParams = {
    orderItemList: Commodity[] | null,
    shops_id: string | null,
    shops_title: string | undefined,
    address_id: string | undefined,
    total_fee: number,
    status: number,
    tableware: boolean,
    remark: string,
    count:number
}
export type ResponseAddOrder = {
    code: number,
    msg: string,
    data: addOrderParams
}
export const addOrderAPI = async (data: addOrderParams) => {
    return await request<ResponseAddOrder>({
        method: "POST",
        url: `${URL}/addOrder`,
        data
    })
}
export type ResponseGetOrder = {
    code: number,
    msg: string
    data:orderDataArr[],
}
export type orderDataArr = {
    address_id: string,
    create_time: number,
    orderItemList_id: orderItemListType[],
    remark: string,
    shops_id: string,
    shops_title: string,
    status: number,
    tableware: boolean,
    total_fee: number,
    user_id: string,
    _id: string,
    count:number
}
type orderItemListType =  {orderItemList: Commodity[]}

export const getOrderAPI = async () => {
    return request<ResponseGetOrder>({
        method: 'GET',
        url: `${URL}/getOrder`
    })
}